<script setup>
import {useUserStore} from '@/stores/user.js';
import {useRouter} from "vue-router";

const {currentUserInfo,updateCurrentAddress} = useUserStore();
const router = useRouter();
let addressList;
if (!currentUserInfo) {
  console.log(55)

  alert("请先登录")
  router.push("/login")
  currentUserInfo.addressList = {name:'未登录'};

}
addressList = currentUserInfo.addressList;

const chooseAddress=(address)=>{
  updateCurrentAddress(address);
router.go(-1)
}
</script>

<template>
  <div class="card" v-for="(item, index) in addressList" @click="chooseAddress(item)">
    <div class="info">
      <div class="name">{{ item.name }}</div>
      <div class="tel">{{ item.phone }}</div>
    </div>
    <div class="address_text">{{ item.address_text }}</div>
  </div>
</template>

<style lang="scss" scoped>
@import '@/style/viriables.scss';

.card {
  margin: .18rem;
  padding: .18rem;
  background-color: $bgColor;
  border-radius: .04rem;
  font-size: .14rem;

  .info {
    display: flex;
    justify-content: space-between;
    margin-bottom: .08rem;
    color: $light-fontColor;

    div {
      flex: 1;
    }
  }
}
</style>